package com.otv.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "rolee")
public class Role implements Serializable {

	private Role superRole;

	private static final long serialVersionUID = 1L;
	private Long id;
	private String nom;

	private Enseigne enseigne;

	private List childrenRoles;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "idEnseigne")
	public Enseigne getEnseigne() {
		return enseigne;
	}

	public void setEnseigne(Enseigne enseigne) {
		this.enseigne = enseigne;
	}

	@OneToMany(mappedBy = "superRole", targetEntity = Role.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	public List getChildrenRoles() {
		return childrenRoles;
	}

	public void setChildrenRoles(List childrenRoles) {
		this.childrenRoles = childrenRoles;
	}

	@ManyToOne
	@JoinColumn(name = "super_role")
	public Role getSuperRole() {
		
			
		return superRole;
	}

	public void setSuperRole(Role superRole) {
		this.superRole = superRole;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return super.hashCode();
	}

	@Override
	public String toString() {
		      
		return nom.toString();
	}
}
